package com.xjgc.eip.panel.controller;


import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xjgc.common.entity.ReturnResult;
import com.xjgc.eip.panel.entity.ZxjEipDnbNycs;
import com.xjgc.eip.panel.mapper.ZxjEipDnbNycsMapper;
import com.xjgc.eip.panel.service.ZxjEipDnbNycsService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wxy
 * @since 2019-11-07
 */
@RestController
@RequestMapping("/zxjEipDnbNycs/")
public class ZxjEipDnbNycsController {
   @Autowired
    private ZxjEipDnbNycsService zxjEipDnbNycsService;
   @Autowired
   private ZxjEipDnbNycsMapper zxjEipDnbNycsMapper;
   @RequestMapping("paramIntro")
    public ReturnResult paramIntro(Integer amount,@RequestHeader("supplierCode")String supplierCode){
       amount=(amount==null)?1:amount;
       Map map=new HashMap();
       map.put("amount",amount);
       map.put("SUPPLIER_CODE",supplierCode);
       List<ZxjEipDnbNycs> list = zxjEipDnbNycsMapper.selectNo(map);
      /* ZxjEipDnbNycs zxjEipDnbNycs = new ZxjEipDnbNycs();
       zxjEipDnbNycs.setIoflag(1);
       QueryWrapper<ZxjEipDnbNycs> queryWrapper = new QueryWrapper<>();
       queryWrapper.setEntity(zxjEipDnbNycs);
       queryWrapper.orderByAsc("\"CREATE_TIME\"");
       Page<ZxjEipDnbNycs> page = new Page<>(1,amount);*/
       ReturnResult returnResult = new ReturnResult();
      /* zxjEipDnbNycsService.page(page,queryWrapper).getRecords();
       List<ZxjEipDnbNycs> list = zxjEipDnbNycsService.page(page,queryWrapper).getRecords();*/
       returnResult.setData(list);
       if(list!=null&&list.size()>0){
           for (ZxjEipDnbNycs zed:list) {
               zed.setIoflag(0);
               zed.setGrabTime(new Date());
           }
           zxjEipDnbNycsService.updateBatchById(list);
       }

       return returnResult;
    }

    @RequestMapping("list")
    public Result list(@RequestHeader(value = "supplierCode" ,required = false)String supplierCode, ZxjEipDnbNycs zxjEipDnbNycs){
       String testCode = zxjEipDnbNycs.getTestCode();
       supplierCode=supplierCode==null?"1000069096":supplierCode;
       List<ZxjEipDnbNycs> list = zxjEipDnbNycsService.list(testCode, supplierCode);
       Page<ZxjEipDnbNycs> page = new Page<>();
       page.setRecords(list);
       return Result.ok(page);
    }
}

